package fr.grassaud.hmvc.sample;

import fr.grassaud.hmvc.component.View;
import fr.grassaud.hmvc.event.HMVCEvent;
import fr.grassaud.hmvc.event.OnInit;
import fr.grassaud.hmvc.session.HMVCSession;
import fr.grassaud.hmvc.session.SessionContext;


@View(controlledBy=SampleController.class)
public class SampleView {

    private String init = "NO";
    
    @SessionContext
    private HMVCSession session;
    
    @OnInit
    private void init() {
	init = "OK";
    }
    
    
    
    public String getInit() {
	return this.init;
    }
    
    
    
    public void sendEvent() {
	session.sendViewEvent(this, new HMVCEvent("getModel",this));
    }
    
    public void sendUnknownEvent() {
	session.sendViewEvent(this,new HMVCEvent("uu",this));
    }
    
    
    public void sendDynamicChildEvent() {
	ChildEvent event = new ChildEvent(this);
	event.setData("dynmaic child event from view");
	session.sendViewEvent(this, event);
	
    }
}
